<?php
namespace app\modules\index\services;

use app\common\services\BaseService;
use app\models\GoodsAttribute;

class GoodsAttributeService extends BaseService{

    /**
     * 搜索
     * @param $goods_attr_id
     * @param $goods_id
     * @param $attr_id
     * @return array|\yii\db\ActiveRecord[]
     */
    public static function search($goods_attr_id,$goods_id,$attr_id){
        $query = GoodsAttribute::find()->asArray(true);

        if(!empty($goods_attr_id)){
            $query->andWhere(['goods_attr_id'=>$goods_attr_id]);
        }
        if(!empty($goods_id)){
            $query->andWhere(['goods_id'=>$goods_id]);
        }
        if(!empty($attr_id)){
            $query->andWhere(['attr_id'=>$attr_id]);
        }

        return $query->all();
    }
}
